<template>
    <div>
        <el-table
            ref="customerTable"
            :data="tableData"
            stripe
            style="width: 100%"
            border
            @selection-change="getSelectVal"
        >
            <el-table-column type="selection" width="55" align="center">
            </el-table-column>
            <el-table-column
                prop="customerName"
                label="客户名称"
            ></el-table-column>
            <el-table-column prop="telPhone" label="电话"></el-table-column>
            <el-table-column
                prop="createTime"
                label="创建时间"
            ></el-table-column>
            <el-table-column prop="status" label="状态">
                <template slot-scope="scope">
                    <span>{{
                        scope.row.status === "0" ? "正常" : "异常"
                    }}</span>
                </template>
            </el-table-column>
        </el-table>
        <el-pagination
            class="pagination mt10"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="currentPage"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            background
        >
        </el-pagination>
    </div>
</template>

<script>
import { getCustomerList } from "@/api/base/data";
export default {
    data() {
        return {
            tableData: [],
            currentPage: 1, //当前页
            pageSize: 10, //每页条数
            total: 0,
        };
    },
    methods: {
        //分页器size
        handleSizeChange(val) {
            this.pageSize = val;
            this.getDataList();
        },
        //分页器当前页
        handleCurrentChange(val) {
            this.currentPage = val;
            this.getDataList();
        },
        getSelectVal(val) {
            // if (val.length) {
            this.$emit("update:visible", false);
            this.$emit("getSelectVal", val);
            // }
        },
        getDataList() {
            // let type = 3;
            // let state = 2;
            // let isUsed = 0;
            getCustomerList().then((res) => {
                this.tableData = res.rows;
                this.total = res.total;
            });
        },
    },
    mounted() {
        this.getDataList();
    },
};
</script>

<style></style>
